# 元祖使用()赋值
tuple = (1, 3, 7, 4, 2)
print(tuple[:3])
print(tuple[2:])

# 元组内的元素不可以修改
# 下面这行会报错，TypeError: 'tuple' object does not support item assignment
# tuple[2] = 1

temp = (1)
print(type(temp))  # int类型
# 只有一个元素的元组
temp = (1,)  # 或temp = 1,
print(type(temp))  # tuple类型

# 也可以不加()
temp = 1, 2, 3
print(type(temp))

# 空元祖
temp = ()
print(type(temp))

# 在元组任意位置插入值
temp = (110, 'dylan', 3.14, [1, 2], (3, 4))
print(temp)
# 插入的值一定要加 ()和 ,
temp = temp[:1] + ('dylan2',) + temp[1:]
print(temp)

# 删除元组
del temp
# 以下会报错：NameError: name 'temp' is not defined
# print(temp)
